//
//  SegmentDownload.h
//  SegmentDownloadDemo
//
//  Created by gao on 2018/5/29.
//  Copyright © 2018年 gao. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SegmentDownloadTask.h"
#import "SegmentDownloader.h"
#import "SegmentDownloadProtocol.h"
@interface SegmentDownload : NSObject
@property(nonatomic,strong)NSURLSession *downloadSession;
+(instancetype)share;

+(void)queryTaskWithTaskDescription:(NSString *)taskDescription completion:(void(^)(SegmentDownloadTask *task,SegmentDownloader *downloader,SegmentDownloadTask_SubTask *subTask,NSInteger subTaskIndex))completion;
+(void)updateDownloadTask:(SegmentDownloadTask *)downloadTask status:(DownloadTaskStatus)status;
+(SegmentDownloadTask *)addDownloadTaskWithURL:(NSURL *)URL totalBytes:(NSInteger)totalBytes;
+(SegmentDownloadTask *)getDownloadTaskWithURL:(NSURL *)URL;

+(NSString *)filePathWithFileName:(NSString *)fileName;

+(void)configMaxConcurrent:(NSInteger)maxConcurrent;
+(void)prepareDownloading:(SegmentDownloadTask *)task;
+(void)startDownload;
+(void)stopDownload;
+(BOOL)allTaskFinished;
+(void)downloaderStartWork;
+(void)saveDownloadData;
+(void)clean;
+(void)cleanDownloadSubTaskDownloadTask;

+(void)addMessageReceiver:(id<SegmentDownloadProtocol>)receiver;
+(void)setMessageReceiverContainer:(id)container;
+(id<SegmentDownloadProtocol>)getReceiverWithDownloadTask:(SegmentDownloadTask *)task;
+(void)cleanMessageReceivers;
@end
